cmake_minimum_required(VERSION 3.4)
set(PROJ_NAME case17)
project(${PROJ_NAME})

execute_process(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/test.py GetFiles
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    RESULT_VARIABLE V_RESULT
    OUTPUT_VARIABLE V_OUTPUT
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )

if (NOT ${V_RESULT} EQUAL 0)
    message(FATAL "Get source files error!!!")
endif()

string(REGEX MATCHALL [^\n]+ V_LIST ${V_OUTPUT})

# set_source_files_properties(${V_LIST} PROPERTIES GENERATED ON)
add_executable(${PROJ_NAME} ${V_LIST})

add_custom_command(OUTPUT ${V_LIST}
    COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/test.py CreateFiles ${CMAKE_CURRENT_BINARY_DIR}
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/test.py
    )
